package cn.wuyu.baselibrary.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.wuyu.baselibrary.R;


/**
 * Created by xuzongmeng on 2016/10/28.
 * X
 */

@SuppressLint("ViewConstructor")
public class EmptyView extends LinearLayout{
    private String hintText;
    private  int imageRes;
    private View view;

    public EmptyView(Context context, String hintText, int imageRes) {
        super(context);
        this.hintText = hintText;
        this.imageRes = imageRes;
        initView(context);
    }

    public EmptyView(Context context, String hintText) {
        super(context);
        this.hintText = hintText;
        initView(context);
    }
    private void initView(Context context) {
        view = LayoutInflater.from(context).inflate(R.layout.view_empty_page, this,true);
        TextView textView = view.findViewById(R.id.empty_text);
        ImageView emptyImg = view.findViewById(R.id.empty_img);
        if (!TextUtils.isEmpty(hintText)){
            textView.setText(hintText);
        }
        if (imageRes!=0){
            emptyImg.setImageResource(imageRes);
        }
    }
    public View getEmptyView() {
        return view;
    }
}
